package com.spzx.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.product.api.domain.Brand;
import com.spzx.product.mapper.BrandMapper;
import com.spzx.product.service.BrandService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl extends ServiceImpl<BrandMapper , Brand> implements BrandService{
    @Override
    public List<Brand> selectBrandList(Brand brand) {


        return baseMapper.selectBrandList(brand);
    }

    @Override
    public boolean checkBrandNameUnique(Brand brand) {
        Long brandId = brand.getId()==null? -1L : brand.getId();
      Brand selectBrand  =baseMapper.checkBrandNameUnique(brand.getName());
      if (selectBrand!=null&&selectBrand.getId().longValue()!=brandId.longValue()){
          return  false;
      }


        return  true;
    }

    @Override
    public int insertBrand(Brand brand) {
        return baseMapper.insertBrand(brand);
    }

    @Override
    public int updateBrand(Brand brand) {


        return baseMapper.updateBrand(brand);
    }

    @Override
    public int removeByBrandId(List<Long> brandIds) {



        return baseMapper.removeByBrandId(brandIds);
    }
}
